#!/bin/bash

cd /home/molio/db_storage/backup/sync

filename=${1-barda}.sql
save_path=$HOME/workspaces/bar-database/.jenkins/barda.tar.gz

run_barda() {
    echo "select '开始导入barda数据库的存储过程...';" >> $1
    cat bak_barda_pfv.sql >> $1
    echo "select 'barda数据库的存储过程导入完成!!!';" >> $1
}

run_rabc() {
    echo "select '开始导入rabc数据库的存储过程...';" >> $1
    cat bak_rabc_pfv.sql >> $1
    echo "select 'rabc数据库的存储过程导入完成!!!';" >> $1
}


cmd=${2-all}
echo '' > $filename
case $cmd in
    barda)
        run_barda $filename
        ;;
    rabc)
        run_rabc $filename
        ;;
    *)
        run_barda $filename
        run_rabc $filename
        ;;
esac

tar -czf $save_path $filename
